package manager;

import entity.ClassRoomBlock;
import iface.IManager;
import java.util.ArrayList;

/**
 *
 * @author Noi
 */
public class ClassRoomBlockManager implements IManager<ClassRoomBlock> {

    private ArrayList<ClassRoomBlock> classBlockList;

    public ClassRoomBlockManager() {
        this.classBlockList = new ArrayList<ClassRoomBlock>();
    }

    @Override
    public boolean add(ClassRoomBlock obj) {
        return this.classBlockList.add(obj);
    }

    @Override
    public boolean remove(ClassRoomBlock obj) {
        return this.classBlockList.remove(obj);
    }

    @Override
    public ClassRoomBlock replace(int index, ClassRoomBlock obj) {
        return this.classBlockList.set(index, obj);
    }

    @Override
    public ClassRoomBlock getById(int id) {
        for (ClassRoomBlock obj : this.classBlockList) {
            if (obj.getClassRoomBlockID() == id) {
                return obj;
            }
        }
        return null;
    }

    @Override
    public int size() {
        return this.classBlockList.size();
    }

    @Override
    public ClassRoomBlock get(int index) {
        return this.classBlockList.get(index);
    }

    @Override
    public ClassRoomBlock getByName(String classRoomBlockName) {
        for (ClassRoomBlock obj : this.classBlockList) {
            if (obj.getClassRoomBlockName().equals(classRoomBlockName)) {
                return obj;
            }
        }
        return null;
    }

    @Override
    public void setVisible(ClassRoomBlock block, boolean value) {
        for (ClassRoomBlock obj : this.classBlockList) {
            if (obj.getClassRoomBlockID() == block.getClassRoomBlockID()) {
                obj.setStatus(value);
            }
        }
    }

    public boolean contains(String blockName) {
        for (ClassRoomBlock block : this.classBlockList) {
            if (block.getClassRoomBlockName().equals(blockName)) {
                return true;
            }
        }
        return false;
    }
}